<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- react的根元素 插入一个根组件 -->
    <div id="example"></div>
</body>
</html>
<script src="./js/react.development.js"></script>
<script src="./js/react-dom.development.js"></script>
<script src="./js/babel.js"></script>
<script type="text/babel">
    class MyComponent extends React.Component{
        constructor(props)
        {
            super(props)
            this.state = {
                username: ''
            }

            this.changeUsername = this.changeUsername.bind(this)
        }

        changeUsername(e)
        { 
            this.setState({
                username: e.target.value
            })
        }

        render() {
            return(
                <div>
                    <h4>表单输入</h4>
                    <input type="text" value={this.state.username} onChange={this.changeUsername} />
                    <p>输入结果为：{this.state.username}</p>
                </div>
            )
        }
    }

    ReactDOM.render(
        <MyComponent />,
        document.getElementById('example')
    )
</script>